package com.yonyong.tao.config;

import com.yonyong.tao.commons.constant.GlobalVar;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class ResourceConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置文件资源映射路径
        registry.addResourceHandler("/"+GlobalVar.FILE_MAPPING_PATH+"/**").addResourceLocations("file:" + GlobalVar.UPLOAD_BASE_PATH);
        //配置项目静态资源访问 只允许访问temp文件夹下内容
        registry.addResourceHandler("/static/temp/**").addResourceLocations("classpath:/static/temp/");
        super.addResourceHandlers(registry);
    }
}
